package cn.taskservice.common.utils.page;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageResult<T> implements Serializable {
    private long total;        // 总记录数
    private long pageNum;      // 当前页码
    private long pageSize;     // 每页条数
    private long pages;        // 总页数
    private List<T> records;   // 当前页数据

    public PageResult(long total, long pageNum, long pageSize, List<T> records) {
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.records = records;
        this.pages = (long) Math.ceil((double) total / pageSize);
    }
}
